function cl = cluster(data,num_sensors,clusters)

    cldims=data(:,3); %[data(:,1) data(:,2) data(:,3)];
    label=emgm(cldims',clusters);
    
    % dim_plot=[1 2 3]
    % dim_plot=[data(:,dim_plot(1)),data(:,dim_plot(2)),data(:,dim_plot(3))];
    % spread(dim_plot',label);

    cl=[];
    for i=1:num_sensors
        vec=data(:,5)==i;
        vec=vec.*label';
        vec([vec==0])=[];
        if length(vec)>0
            rij=[];
            highest=0;
            clust=0;
            for j=1:clusters
                som=sum(vec(:,1)==j);
                rij=[rij som];
                if som>highest
                    highest=som;
                    clust=j;
                end
            end
            cl=[cl;i clust rij];
        end
    end

end

